/*
 * 矩阵转置（4分）
 *
 * v1.0见08-week08/7_Matrix_Transposition_v1.c
 */

#include <stdio.h>

int main() {
	setbuf(stdout, NULL);

	int n;

	scanf("%d", &n);

	// 数组初始化
	int data[n][n];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			data[i][j] = i * n + j + 1;
		}
	}

	printf("The original matrix is:\n");
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			printf("%3d", data[i][j]);
		}
		printf("\n");
	}

	printf("The changed matrix is:\n");
	for (int j = 0; j < n; ++j) {
		for (int i = 0; i < n; ++i) {
			printf("%3d", data[i][j]);
		}
		printf("\n");
	}

	return 0;
}